home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 12 / Cream of the Crop 12 (Part II) / Cream of the Crop 12 (Part II).iso / OS2 / FIX500S.ZIP / FIX.H < prev    next >
Encoding:
C/C++ Source or Header  |  1996-01-01  |  5.2 KB  |  97 lines

  1. /************************************************************* fix.h 01-96
  2.  *  Program ... FIX Library Function
  3.  *  File ...... FIX.H
  4.  *  Version ... 5.00F
  5.  *  Date ...... 1 January 1996
  6.  *  Purpose ... Function Documentation & Header File for C/C++ Program
  7.  *
  8.  *  Copyright (C) 1993-1996 Novalogic.  All Rights Reserved.
  9.  *
  10.  *************************************************************************
  11.  *    intro: The basic string find/replace algorithm of the FIX util-
  12.  *           ity is available for incorporation in your internal or
  13.  *           commercial software project.  Don't reinvent the wheel.
  14.  * function: FIX 5.00F Find/replace string occurrences in IBM-PC file.
  15.  *           Assembled 16 bit code, optimized for speed, 1,950 bytes,
  16.  *           C call convention, supports all modes & memory models,
  17.  *           reentrant if user provides reentrant read/write functions.
  18.  * requires: Intel 8086 or higher processor, protected mode operation
  19.  *           requires DPMI (Windows 3.X), else if no ms-dos user must
  20.  *           provide file read/write functions to be called by FIX
  21.  *   limits: i/o file size:  limited only by available drive space
  22.  *           string length:  max approx 6,000 bytes with 0xFFFF buffer
  23.  *           buffer_size:    max = 0xFFFF bytes,
  24.  *                           min = 128 + 9*find_len + replace_len
  25.  * licensor: NovaLogic  (503) 524-9184  novalogic@teleport.com
  26.  *           13585 SW Pommel Ct,  Beaverton, OR 97008  USA
  27.  ************************************************************************/
  28. #ifndef __FIX_H
  29. #define __FIX_H
  30. /* function prototype: */
  31. #define ulong unsigned long
  32. /* err_code =              /* error code returned by Fix (see below) */
  33. int Fix (                  /* Fix library function */
  34.     int    cntrl_flags,    /* control bit flags */
  35.     int    infile_hndl,    /* handle of opened input file or device */
  36.     int    outfile_hndl,   /* handle of opened output file or device */
  37.     char  *find_string,    /* pointer to find string */
  38.     int    find_len,       /* length of find string [1] */
  39.     char  *replace_string, /* pointer to replace string */
  40.     int    replace_len,    /* length of replace string */
  41.     char  *buffer,         /* ptr working buffer reserved by caller */
  42.     int    buffer_size,    /* size of working buffer, max 0xFFFF */
  43.     ulong *string_count ); /* ptr to found/replaced string counter */
  44.  
  45. /* cntrl_flags bit flags: */
  46. #define FIX_COUNT_ONLY    0x0001  /* only count findstrings */
  47. #define FIX_CASE_INSENS   0x0002  /* case insensitive search */
  48. #define FIX_DELIM_FINDSTR 0x0004  /* select only delimited [2] findstr */
  49. #define FIX_BEGIN_LINE    0x0008  /* begin file = begin line (^) [3] */
  50. #define FIX_END_LINE      0x0010  /* end file = end line ($) [3] */
  51. #define FIX_UNIX_TEXT     0x0020  /* Unix newline for (^),($),(\n) [3] */
  52. #define FIX_UPPER_CASE    0x0040  /* transform all text upper case [4] */
  53. #define FIX_LOWER_CASE    0x0080  /* transform all text lower case [4] */
  54. /*                        0x0X00  /* 4 bits reserved for future FIX use */
  55. /*              0xX000  /* 4 bits for user's cntrl of user */
  56. /* Notes: */                      /*       written read/write functions */
  57. /* [1] To copy infile to outfile, set find_len to zero.
  58.  * [2] A 'delimited' findstring is immediately preceded & followed in
  59.  *     text by a char outside of the ranges: [0-9], [A-Z], [a-z], [_].
  60.  * [3] Setting FIX_BEGIN_LINE or FIX_END_LINE flag assumes that
  61.  *     find_string begins or ends with newline chars.  Default newline
  62.  *     is MS-DOS' 0x0D,0x0A, set FIX_UNIX_TEXT for Unix newline 0x0A.
  63.  * [4] When an upper or lower case transform bit flag is set, no other
  64.  *     flags are permitted */
  65.  
  66. /* err_code values: */
  67. #define FIXERR_NONE         0  /* no error, successful execution */
  68. #define FIXERR_CNTRL_FLAGS  1  /* incompatible control flags received */
  69. #define FIXERR_BUFSIZE      2  /* insufficient buffer space provided */
  70. #define FIXERR_INFILE_HNDL  3  /* infile handle invalid or not open */
  71. #define FIXERR_INFILE_ACCS  4  /* infile access denied */
  72. #define FIXERR_OUTFILE_HNDL 5  /* outfile handle invalid or not open */
  73. #define FIXERR_OUTFILE_ACCS 6  /* outfile access denied */
  74. #define FIXERR_DRIVEFULL    7  /* insufficient free space output drive */
  75.  
  76. /* prototypes for sequential read/write functions which must be */
  77. /* provided by user for operating systems other than ms-dos: */
  78.  
  79. /* int return_count =       /* returned count of bytes read */
  80. int fix_read (              /* sequential read function called by Fix() */
  81.     int  *err_code,     /* NONE, INFILE_HNDL, INFILE_ACSS */
  82.     char *buffer,       /* buffer for text to be read */
  83.     int   byte_count,   /* count of bytes to be read */
  84.     int   file_handle,  /* handle of input file */
  85.     int   cntrl_flags); /* control bit flags (optional) */
  86.  
  87. /* int return_count =       /* returned count of bytes written */
  88. int fix_write (             /* sequential write function called by Fix()*/
  89.     int  *err_code,     /* NONE,OUTFILE_HNDL,OUTFILE_ACSS,DRIVEFULL */
  90.     char *buffer,       /* buffer containing text to be written */
  91.     int   count,        /* count of bytes to be written */
  92.     int   handle,        /* handle of output file */
  93.     int   cntrl_flags); /* control bit flags (optional) */
  94.  
  95. #endif
  96. /* end of FIX.H */
  97.